Import('RTT_ROOT')
Import('rtconfig')
from building import *

cwd     = os.path.join(str(Dir('#')), 'drivers')

# add the general drivers.
src = Split("""
board.c
platform.c
delay.c
stm32f4xx_it.c
""")

# add Ethernet drivers.
if GetDepend('RT_USING_LWIP'):
    src += ['stm32f4xx_eth.c']

# add gpio drivers.
if GetDepend('RT_USING_PIN'):
    src += ['gpio.c']

# add uart drivers.
if GetDepend('RT_USING_SERIAL'):
    src += ['usart.c']

# add rtc drivers.
if GetDepend('RT_USING_RTC'):
    src += ['rtc.c']

# add i2c_soft drivers
if GetDepend('RT_USING_I2C'):
    if GetDepend('RT_USING_I2C_BITOPS'):
        src += ['i2c_soft.c']
        src += ['at24cxx.c']
    else:
        src += ['i2c_hard.c']
        src += ['at24cxx.c']

# add 1_wire driver
if GetDepend('RT_USING_ONE_WIRE'):
    src += ['drv_1wire.c']
    if GetDepend('RT_USING_DS18B20'):
        src += ['ds18b20.c']

# add key driver
if GetDepend('RT_USING_GPIO_KEY'):
    src += ['gpio_key.c']

# add led driver
if GetDepend('RT_USING_GPIO_LED'):
    src += ['gpio_led.c']

# add gpio_misc driver
if GetDepend('RT_USING_GPIO_MISC'):
    src += ['gpio_misc.c']

# add sdcard driver
if GetDepend('RT_USING_SDCARD'):
    src += ['sdcard.c']

# add spi driver
if GetDepend('RT_USING_SPI'):
    src += ['spi_drv.c']

# add adc driver
if GetDepend('RT_USING_ADC'):
    src += ['adc.c']

# add infrared driver
if GetDepend('RT_USING_INFRARED'):
    src += ['infrared.c']

CPPPATH = [cwd]

group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)

Return('group')
